package instrument;

import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;

public class LogUtil {
    private static final String FILE = "operation.log";
    private static final SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public static void log(String operator, String action) {
        String line = SDF.format(new Date()) + " [" + operator + "] " + action;
        try (PrintWriter pw = new PrintWriter(new FileWriter(FILE, true))) {
            pw.println(line);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}